package com.ywjt.pinkelephant.util;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;

import java.util.Stack;

/**
 * Activity 滑动返回组件
 */
public class ActivityStackUtil implements Application.ActivityLifecycleCallbacks {

    private Stack<Activity> mActivityStack = new Stack<>();
    Handler mHandler = new Handler();
    private Activity mCurrentActivity;
    //初始化AutoTouch对象
    private Context mContext;
    private boolean isWebView=false;




    private static class Holder {
       public static ActivityStackUtil sInstance = new ActivityStackUtil();
    }

    public static ActivityStackUtil getInstance() { return Holder.sInstance;}

    public void init(Application application) {
        mContext=application;
        application.registerActivityLifecycleCallbacks(this);
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        mActivityStack.push(activity);
    }

    @Override
    public void onActivityStarted(Activity activity) { }

    @Override
    public void onActivityResumed(Activity activity) {

    }

    @Override
    public void onActivityPaused(Activity activity) { }

    @Override
    public void onActivityStopped(Activity activity) { }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) { }

    @Override
    public void onActivityDestroyed(Activity activity) { mActivityStack.remove(activity); }
}